﻿using System.Windows;
using System.Windows.Browser;
using HelloWorld.Controls;
using HelloWorld.Shared.Models;

namespace HelloWorld
{
    /// <summary>
    /// Remove the DoitControl property, add the ClickDoitControl method
    /// Notice that Doit Button doesn't have the OnClick method!!
    /// </summary>
    [ScriptableType]    
    public partial class Demo5
    {
        private readonly MainPageModel _model = new MainPageModel();

        public Demo5()
        {
            InitializeComponent();
            DataContext = _model;
        }

        public MyRadioButton EatControl
        {
            get
            {
                return Eat;
            }
        }
        
        public string Result
        {
            get
            {
                return result.Text;
            }
        }

        public bool IsProcessing
        {
            get
            {
                return _model.IsProcessing;
            }
        }

        public void ClickDoitControl()
        {
            // Doit.OnClick();
            Doit.DoClick();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            _model.Doit();
        }

        private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
        {
            // Tell the browser that it can interact with this page
            HtmlPage.RegisterScriptableObject("Sample", this);
        }
    }
}
